package gpush

import (
	"bytes"
	"gitee.com/s2-r/goutils/gson"
	"net/http"
)

type Message struct {
	Id   int64  `json:"id"`
	Tag  string `json:"tag"`
	Body string `json:"body"`
	Time int64  `json:"time"`
}

func (m *Message) send(url string) bool {
	json := gson.ToJson(m)
	req, err := http.NewRequest("POST", url, bytes.NewBuffer([]byte(json)))
	if err != nil {
		panic(err)
		return false
	}
	req.Header.Set("Content-Type", "application/json")
	client := &http.Client{}
	resp, err := client.Do(req)
	defer resp.Body.Close()
	if err != nil {
		panic(err)
		return false
	}
	return true
}
